package yangsw87.basic;

public class J15_Ex74_Interface {

	public static void main(String[] args) {
		J15_AccountServiceImpl acsrv = new J15_AccountServiceImpl();

		J15_Account ac = new J15_Account(1122, 20000, 4.5,
				"2014-08-15 14:34:29");

		ac.setMonthlyInterestRate(acsrv.getMonthlyInterestRate(ac));

		System.out.println(ac.toString());
	}

}

interface J15_AccountService {
	double getMonthlyInterestRate(J15_Account ac);
}

class J15_AccountServiceImpl implements J15_AccountService {

	@Override
	public double getMonthlyInterestRate(J15_Account ac) {
		double MonthlyInterestRate = ac.getMonthlyInterestRate() / 12;
		return MonthlyInterestRate;
	}

}

class J15_Account {
	private int aid;
	private int balance;
	private double interestRate;
	private String dateCreated;

	private double MonthlyInterestRate;

	public J15_Account() {
		int aid = 0;
		int balance = 0;
		double interestRate = 0;
	}

	public J15_Account(int aid, int balance, double interestRate,
			String dateCreated) {
		this.aid = aid;
		this.balance = balance;
		this.interestRate = interestRate;
		this.dateCreated = dateCreated;
	}

	public int getAid() {
		return aid;
	}

	public void setAid(int aid) {
		this.aid = aid;
	}

	public int getBalance() {
		return balance;
	}

	public void setBalance(int balance) {
		this.balance = balance;
	}

	public double getInterestRate() {
		return interestRate;
	}

	public void setInterestRate(double interestRate) {
		this.interestRate = interestRate;
	}

	public String getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(String dateCreated) {
		this.dateCreated = dateCreated;
	}

	public double getMonthlyInterestRate() {
		return MonthlyInterestRate;
	}

	public void setMonthlyInterestRate(double MonthlyInterestRate) {
		this.MonthlyInterestRate = MonthlyInterestRate;
	}

	@Override
	public String toString() {
		return "J15_Account [aid=" + aid + ", balance=" + balance
				+ ", interestRate=" + interestRate + ", dateCreated="
				+ dateCreated + ", MonthlyInterestRate=" + MonthlyInterestRate
				+ "]";
	}

}
